package com.hiedu.controller;

import com.hiedu.beans.vo.OrderVO;
import com.hiedu.beans.vo.ProductVO;
import com.hiedu.service.OrderItemService;
import com.hiedu.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ProjectName: hi-app
 * @Titile: OrderController
 * @Author: Lucky
 * @Description: 订单控制类
 */
@Controller
@RestController
@RequestMapping("/api/order")
public class OrderController {
    @Autowired
    private OrderItemService orderItemService;

    @Autowired
    private OrderService orderService;
    /**
     * 根据订单项获取商品信息
     * @param id 订单项编号
     * @return
     */
    @GetMapping("item/{id}")
    public Object getProductByOrderItemId(@PathVariable Integer id){
        ProductVO productVO = orderItemService.getProductById(id);
        return productVO;
    }


    @GetMapping("list/{userId}")
    public Object getOrderList(@PathVariable Integer userId){
        List<OrderVO> orderList = orderService.getOrderList(userId);
        return orderList;
    }

}